package com.imoonfish.bet.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.imoonfish.bet.R;
import com.imoonfish.bet.entity.Fruit;

import java.util.List;

public class FruitAdapter extends ArrayAdapter<Fruit> {
    private int resourceId;
    public FruitAdapter(Context context, int resource, List<Fruit> objects) {
        super(context, resource, objects);
        resourceId=resource;
    }

    @Override
    public View getView(int position,  View convertView, ViewGroup parent) {
        Fruit fruit=getItem(position);
        View view=LayoutInflater.from(getContext()).inflate(resourceId,parent,false);
        ImageView fruitImag=(ImageView)view.findViewById(R.id.fruit_img);
        TextView fruitName=(TextView)view.findViewById(R.id.fruit_name);
        fruitImag.setImageResource(fruit.getFruitImageID());
        fruitName.setText(fruit.getFruitName());
        return view;
    }
}
